import sys
sys.path.append('../')
if '__file__' in globals():
    import os, sys
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import numpy as np
from common.util import preprocess
from common.util import create_co_matrix

text = 'You say goodbye and I say hello.'
corpus, word_to_id, id_to_word = preprocess(text)

print('corpus: \n', corpus)

print('id_to_word: \n', id_to_word)

def create_co_matrix(corpus, vocab_size, window_size=1):
    matrix = np.zeros((vocab_size, vocab_size), dtype=np.int32)

    for index in range(len(corpus)-1):
        matrix[corpus[index], corpus[index+1]] += 1
        matrix[corpus[index+1], corpus[index]] += 1

    return matrix

print(create_co_matrix(corpus, len(word_to_id), 1))